<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #box {
      width: 200px;
      height: 600px;
      background: pink;
    }
    #content {
      width: 200px;
      height: 200px;
      background-color: red;
    }
  </style>
</head>
<body>
  <div id="box">
    <div id="content"></div>
  </div>
  <script>
    var oBox = document.querySelector('#box')
    var oContent = document.querySelector('#content')
    // scroll事件没有滚动条的时候是不会出触发的
    // oBox.onscroll = function () {
    //   console.log('scroll')
    // }

    // wheel 轮子
    // 这个事件在火狐里不生效
    oBox.onmousewheel = function (e) {
      e = e || window.event
      console.log(e)
      if (e.wheelDeltaY < 0) {
        // 向下
        oContent.style.height = oContent.offsetHeight + 10 + 'px'
      } else {
        // 向上
        oContent.style.height = oContent.offsetHeight - 10 + 'px'
      }
    }

    // 火狐的写法
    oBox.addEventListener('DOMMouseScroll', function (e) {
      console.log(e)
      if (e.detail > 0) {
        // 向下
        oContent.style.height = oContent.offsetHeight + 10 + 'px'
      } else {
        oContent.style.height = oContent.offsetHeight - 10 + 'px'
      }
    })

  </script>
</body>
</html>